home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / c / supralib / developer / source.org / _newimage.c < prev    next >
C/C++ Source or Header  |  1999-06-14  |  3KB  |  78 lines

  1. /***********************************************************************
  2. *
  3. *    ---------------
  4. *   * Supra library *
  5. *    ---------------
  6. *
  7. *   - NewImage demo -
  8. *   Demonstration of ObtPens(), RelPens(), MakeNewImg(), FreeNewImg()
  9. *
  10. *   Program will draw two images. The image on top is a normal unmapped
  11. *   image, the one under it is remapped into true colors.
  12. *   This demo requires some free pens in a workbench palette, otherwise
  13. *   colours will not be very exact.
  14. *   It requires version 39 of graphics.library (AGA Amigas have it).
  15. *
  16. *
  17. *   ©1995 by Jure Vrhovnik -- all rights reserved
  18. *   jurev@gea.fer.uni-lj.si
  19. *
  20. ***********************************************************************/
  21.  
  22. #include <clib/exec_protos.h>
  23. #include <clib/intuition_protos.h>
  24. #include <clib/graphics_protos.h>
  25. #include <intuition/intuition.h>
  26. #include <libraries/supra.h>
  27. #include <stdio.h>
  28.  
  29. extern UWORD data[];
  30. extern ULONG cmap[];
  31. extern struct Image im;
  32.  
  33. struct Library *GfxBase = NULL;
  34. struct Library *IntuitionBase = NULL;
  35.  
  36. struct Screen *scr;
  37. struct Window *win;
  38. struct Image *newimg;
  39. ULONG pal[4];
  40.  
  41. struct TagItem tags[] = {OBP_Precision, PRECISION_EXACT, TAG_DONE};
  42. main()
  43. {
  44.  
  45.     if (IntuitionBase = OpenLibrary("intuition.library", 0)) {
  46.          if (GfxBase = OpenLibrary("graphics.library", 39)) {
  47.             if (scr = LockPubScreen(NULL)) {
  48.                 if (ObtPens(scr->ViewPort.ColorMap, cmap, pal, tags) == 4) {
  49.                     if (win = OpenWindowTags(NULL, WA_Left, 70,
  50.                                                    WA_Top, 70,
  51.                                                    WA_Width, 128,
  52.                                                    WA_Height, 135,
  53.                                                    WA_Title, "New Image Demo",
  54.                                                    TAG_DONE)) {
  55.  
  56.                         if (newimg = MakeNewImg(&im, pal)) {
  57.                             DrawImage(win->RPort, &im, 20, 30);
  58.                             DrawImage(win->RPort, newimg, 20, 80);
  59.                             Delay(200);                                                FreeNewImg(newimg);
  60.                         }
  61.  
  62.  
  63.                         CloseWindow(win);
  64.                     } else printf("Could not open window.\n");
  65.  
  66.                     RelPens(scr->ViewPort.ColorMap, cmap, pal);
  67.                 } else printf("Could not allocate pens.\nNot enough colors\n");
  68.  
  69.                 UnlockPubScreen(NULL, scr);
  70.             }
  71.  
  72.             CloseLibrary(GfxBase);
  73.         }
  74.  
  75.         CloseLibrary(IntuitionBase);
  76.     }
  77. }
  78.